﻿using System.Text;
using Tilver.Coder.DBTextStyle;
using Tilver.Coder.Core;

namespace Tilver.Coder.Engine
{
    /// <summary>
    /// 引擎接口
    /// </summary>
    public interface IEngine
    {
        /// <summary>
        /// 代码生成式样
        /// </summary>
        DBTextStyleBase DBTextStyle { get; set; }
        /// <summary>
        /// 生成代码命名空间
        /// </summary>
        string NameSpace { get; set; }
        /// <summary>
        /// 生成Tab数量
        /// </summary>
        int Tabs { get; set; }
        /// <summary>
        /// 生成代码
        /// </summary>
        /// <returns></returns>
        string RenderToString();
        /// <summary>
        /// 保存生成代码
        /// </summary>
        /// <param name="path"></param>
        void RenderToFile(string path);
    }
    /// <summary>
    /// 表引擎接口
    /// </summary>
    public interface ITableEngine : IEngine
    {
        CoderTable Table { get; set; }
    }
    /// <summary>
    /// 视图引擎接口
    /// </summary>
    public interface IViewEngine : IEngine
    {
        CoderView View { get; set; }
    }
    /// <summary>
    /// 存储过程引擎接口
    /// </summary>
    public interface ICommandEngine : IEngine
    {
        CoderCommand Command { get; set; }
    }
    /// <summary>
    /// 枚举类生成接口
    /// </summary>
    public interface IEnumEngine : IEngine
    {
        CoderEnum Enum { get; set; }
    }
    /// <summary>
    /// 表实体类生成引擎接口
    /// </summary>
    public interface ITableEngineEO : ITableEngine { }
    /// <summary>
    /// 表操作类生成引擎接口
    /// </summary>
    public interface ITableEngineMO : ITableEngine { }
    /// <summary>
    /// 视图实体类生成引擎接口
    /// </summary>
    public interface IViewEngineEO : IViewEngine { }
    /// <summary>
    /// 视图操作类生成引擎接口
    /// </summary>
    public interface IViewEngineMO : IViewEngine { }

    /// <summary>
    /// 代码生成引擎工厂类
    /// </summary>
    public interface IEngineFactory
    {
        ITableEngine GetTableEngine();
        ITableEngineEO GetTableEngineEO();
        ITableEngineMO GetTableEngineMO();
        IViewEngine GetViewEngine();
        IViewEngineEO GetViewEngineEO();
        IViewEngineMO GetViewEngineMO();
        ICommandEngine GetCommandEngine();
    }

    public interface ICommandExecuteResultEngine
    {
        void ResponseExecuteNonQuery(StringBuilder response, int tabs, CoderCommand command);
        void ResponseExecuteScalar(StringBuilder response, int tabs, CoderCommand command);
        void ResponseExecuteSingle(StringBuilder response, int tabs, CoderCommand command);
        void ResponseExecuteReader(StringBuilder response, int tabs, CoderCommand command);
    }

}
